
#include <mockcpp/mockcpp.hpp>
#include <testngpp/testngpp.hpp>
#include <Volume.h>

USING_MOCKCPP_NS
USING_TESTNGPP_NS

FIXTURE(Volume)
{
        TEST(should be able to compare 1 TBSP with 3 TSP)
        {
                Volume tsp(3, TSP);
                Volume tbsp(1, TBSP);

                ASSERT_EQ(true, tsp == tbsp);
        }

        TEST(should be able to compare 2 TBSP with 1 OZ)
        {
                Volume tbsp(2, TBSP);
                Volume oz(1, OZ);

                ASSERT_EQ(true, tbsp == oz);
        }

        TEST(should be able to compare 6 TSP with 1 OZ)
        {
                Volume tsp(6, TSP);
                Volume oz(1, OZ);

                ASSERT_EQ(true, tsp == oz);
        }

        TEST(should be able to compare 1 OZ with 1 TBSP + 3 TSP)
        {
                Volume tsp(3, TSP);
                Volume tbsp(1, TBSP);
                Volume oz(1, OZ);

                ASSERT_EQ(true, oz == tsp + tbsp);
        }

        TEST(should be able to print 28 TSP as 4 OZ 1 TBSP 1 TSP)
        {
                Volume tsp(28, TSP);
                Volume ozAdd(4, OZ);
                Volume tbspAdd(1, TBSP);
                Volume tspAdd(1, TSP);

                ASSERT_EQ(true, tsp == ozAdd + tbspAdd + tspAdd);

                ostringstream volumeStream;
                string volumeString;
                string testString;

                tsp << (volumeStream);
                volumeString = volumeStream.str();
                testString = "4 OZ 1 TBSP 1 TSP";
                ASSERT_EQ(true, volumeString == testString);
        }

        TEST(should be able to print 28 TSP as 28 TSP and also 4 OZ 1 TBSP 1 TSP)
        {
                Volume tsp(28, TSP);

                ostringstream volumeStreamFormat;
                ostringstream volumeStreamInBaseUnit;
                string volumeStringFormat;
                string volumeStringInBaseUnit;
                string testString;

                tsp.output(volumeStreamFormat, VolumeFormatorInStdFormat);
                volumeStringFormat = volumeStreamFormat.str();
                testString = "4 OZ 1 TBSP 1 TSP";
                ASSERT_EQ(true, volumeStringFormat == testString);

                testString.clear();
                tsp.output(volumeStreamInBaseUnit, VolumeFormatorInBaseUnit);
                volumeStringInBaseUnit = volumeStreamInBaseUnit.str();
                testString = "28 TSP";
                ASSERT_EQ(true, volumeStringInBaseUnit == testString);
        }
};

